home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: "Nathan Myers <ncm@cantrip.org>" <ncm@cantrip.org>
- Newsgroups: comp.std.c++
- Subject: Re: Use of standard exception classes
- Date: 13 Apr 1996 23:17:30 GMT
- Organization: Best Internet Communications
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <316F646D.552DF1DD@cantrip.org>
- References: <9604121530.AA08606@sun132.spd.dsccc.com>
- NNTP-Posting-Host: taumet.eng.sun.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Nntp-Posting-Host: ncm.vip.best.com
- X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i386)
- Content-Length: 2404
- Originator: clamage@taumet
-
- Kevin Cline wrote:
- >
- > In "The Standard C++ Library" on page 65, Plauger wrote:
- >
- > "I strongly encourage you to follow the lead of the Standard C++
- > library in the use of exceptions:
- > * Throw only objects of one or more classes derived from [exception]
- >
- > Page 19-1 of the 4/95 version of the draft says "The Standard C++
- > library provides classes to be used to report errors in C++ programs."
- >
- > But in section 19.1.1 of the same draft it says:
- >
- > "The class exception defines the base class for the types of objects
- > thrown as exceptions by *C++ Standard library components*, and certain
- > expressions, to report errors detected during program execution."
- >
- > Can someone on the committee indicate whether it was the committee's
- > intention for the standard exception class hierarchy to be used in
- > general C++ programming, or whether the intention was for the standard
- > exception class hierarchy to be reserved to the Standard C++ library?
-
-
- In discussion that led to the current formulation for the standard
- exception types, it became clear that they are not general enough
- for all uses in user code; the committee agreed that it was sufficient
- to standardize just what is needed for the standard library.
-
- So use your own exception types, if you like; if you derive from
- a standard exception, you probably should use virtual derivation
- for reasons John Skaller seems always happy to explain.
-
-
- > Another developer on our team has asked
- > How can we be sure that ANSI C++ library callbacks work
- > correctly in the face of exceptions? What if ANSI C++
- > library code catches *our* exception?
- >
- > Is this a problem, or are library functions required to reraise any
- > exceptions thrown by client code?
-
- I assume that by "library callbacks" s/he means member functions
- invoked by library components?
-
- Bad things happen if you throw during copy construction or destruction
- of a vector element. Don't let it happen. (Yes, I know this is easier
- said than done. Still.) There are lots of things in the library that
- could break if a user object (or even a standard object!) throws during
- a standard function. Probably there are some places where it would be
- safe, but the committee hasn't identified them except in iostreams, where
- it's specified under what circumstances exceptions are caught and rethrown.
-
- Nathan Myers
- ncm@cantrip.org http://www.cantrip.org/
-
-
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-